<?php
class ControllerModuleFeatured extends Controller {
	protected function index($setting) {
		static $module = 0;
		$this->data['module'] = 'F' . $module++;
		
		$this->language->load('module/featured'); 
		
		M('catalog/product');

		$this->data['products'] = array();

		$products = explode(',', C('featured_product'));		

		if (empty($setting['limit'])) {
			$setting['limit'] = 5;
		}
		
		$product_ids = array_slice($products, 0, (int)$setting['limit']);
		$products = $this->model_catalog_product->getProductByIds($product_ids);
		foreach ($products as $product) {

			$this->data['products'][] = array(
				'product_id' => $product['product_id'],
				'thumb'   	 => thumb($product['image'], $setting['image_width'], $setting['image_height']),
				'name'    	 => $product['name'],
				'price'      => pprintf($product['price'], $product['tax_class_id']),
				'summary'    => $product['summary'],
				'special'    => pprintf($product['special'], $product['tax_class_id']),
				'rating'     => C('config_review_status') ? $product['rating'] : false,
				'reviews'    => sprintf($this->_['text_reviews'], (int)$product['reviews']),
				'href'    	 => $product['link'],
			);
		}
		$this->data['heading_title'] = $this->_['heading_title'];
		$this->render('module/' . (!empty($setting['template']) ? $setting['template'] : 'featured.tpl'));
	}
}
?>